/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.guaraba.internacionalizacao.util;

import java.util.Locale;
import java.util.ResourceBundle;

/**
 *
 * @author Marcelo Gomes
 * marcelogomesrp@gmail.com
 */
public final class Mensagem {
    private ResourceBundle bundle;
    private String fileBundle;
    private Locale local;

    public Mensagem(String fileBundle, Locale local) {
        UpdateLocalFile(fileBundle, local);
    }

    public void UpdateLocalFile(String fileBundle, Locale local){
        this.bundle = ResourceBundle.getBundle(fileBundle, local);
    }

    public Locale getLocal() {
        return local;
    }

    public void setLocal(Locale local) {
        this.local = local;
    }

    public String getValue(String key){
         return bundle.getString(key);
    }

    public static String getValue(String fileBundle, Locale local, String key){
        ResourceBundle bundle = ResourceBundle.getBundle(fileBundle, local);
        return bundle.getString(key);
    }


}



//    public Mensagem() throws IOException {
//        File fileConfig = new File("resorce/config.propertis");
//        if(fileConfig.exists()){
//            PropertiesLoader pl = new PropertiesLoader(fileConfig);
//            fileBundle = pl.getValor("file");
//        }else{
//            fileBundle = "br.com.guaraba.internacionalizacao.resorce.Bundle";
//        }
//        //this.bundle = ResourceBundle.getBundle(fileBundle, new Locale("pt","BR"));
//        this.bundle = ResourceBundle.getBundle(fileBundle, local);
//    }